package com.example.springweb.config;

import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OllamaModelConfig {
	
	@Value("${spring.ai.ollama.base-url:http://127.0.0.1:11434}")
	private String ollamaBaseUrl;
	
	@Value("${spring.ai.ollama.chat.option.model:llama3}")
	private String ollamaChatOptionModel;

	@Bean
	public OllamaChatModel ollamaChatModel() {
        OllamaApi ollamaApi = new OllamaApi(ollamaBaseUrl);
        OllamaChatModel chatModel = OllamaChatModel.builder()
        		.defaultOptions(OllamaOptions.builder().model(ollamaChatOptionModel).build())
        		.ollamaApi(ollamaApi)
        		.build();
        return chatModel;
	}
}
